import Vue from 'vue';
import Vuex from 'vuex';
import getters from '@/store/getters';
import path2var from '@helpers/path2var';

Vue.use(Vuex);

const modules = {};

// 导入模块
const requireModules = require.context('@store/modules', true, /.js$/);
requireModules.keys().forEach((key) => {
    modules[path2var(key)] = requireModules(key).default;
});

const store = new Vuex.Store({
    modules,
    getters
});

export default store;
